package appapi.dao;

import appapi.Request.EquiPageReq;
import appapi.Request.EquipmentPageReq;
import appapi.Vo.AppVo.ExcelEquipVo;
import appapi.Vo.AppVo.ExecelEquipVos;
import appapi.Vo.AppVo.GetEquipList;
import appapi.dto.EquiPageReqModel;
import appapi.entity.Zhongjiao.EquipmentDto;
import appapi.entity.bridge.Equipment;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author dhq
 * @version 1.0
 * @date 2023/9/11  18:03
 */
public interface EquipmentMapper {
    int deleteByPrimaryKey(Long equipId);

    int insert(EquipmentDto dto);

    int insertSelective(EquipmentDto dto);

//    Equipment selectByPrimaryKey(Long equipId);

    int updateByPrimaryKeySelective(EquipmentDto dto);

    int updateByPrimaryKey(Equipment record);

    int deleteByIds(@Param("equipIds") List<Long> equipIds);

    List<Map<String, Object>> selectList(String equip_no);

    List<Map<String, Object>> selectEquiPageList(EquiPageReq dto);

    List<ExecelEquipVos> selectEquiPageLists(EquiPageReq dto);

    List<GetEquipList> selectEquiPage(EquipmentPageReq req);

    EquipmentDto selectWechatCode(Long equipId);

    Map<String, Object> selectEquiDetail(Long equipId);

    List<Map<String, Object>> selectPageList(EquipmentPageReq equipmentPageReq);

    List<EquipmentDto> selectAllByEquipName(@Param("equipName") String equipName);

    GetEquipList selectEquiDetailByNo(String equipNo);

    Map<String, Object> getEquipStateCountByProjAndType(@Param("equipTypeId") Long equipTypeId, @Param("projId") Long projId);

    @Select("SELECT count( a.equip_id ) equipNum,IFNULL(SUM(IF(a.equip_status =0,1,0)),0) useNum from equipment a " +
            "JOIN organization b on a.orga_id =  b.orga_id" +
            " where b.orga_path_ids like CONCAT(#{orgaId,jdbcType=VARCHAR},'%')")
    Map<String, Object> getEquipStateCountByOrgaId(@Param("orgaId") String orgaPath);

    @Select("SELECT count(1) equipNum,IFNULL(SUM(IF(equip_status=0,1,0)),0) useNum from equipment" +
            " where proj_id =#{projId,jdbcType=BIGINT}")
    Map<String, Object> getEquipStateCountByProjId(@Param("projId") Long projId);

    Map<String, Object> getEquipNumByOrga(@Param("orgaIds") List<Long> orgaIds, @Param("projIds") List<Long> projIds, @Param("typeName") String typeName);

    List<EquiPageReqModel> queryList(EquiPageReq equiPageReq);

    List<ExcelEquipVo> EquipmentRecExport(EquiPageReq req);

    List<ExecelEquipVos> EquipmentRecExports(EquiPageReq req);

    Integer getEquipIsDel(@Param("equipIds") List<Long> equipIds);

    EquipmentDto selectByEquipId(Long equipId);
}